<template>
	<view class="container">
		<view class="hotItem" v-for="(item,index) in data" :key="item.id" @click="toDetail(item.mobileUrl)">
			<image :src="item.cover" mode="aspectFill" class="pic" />
			<view class="itemContent">
				<view class="contentTitle two-line-ellipsis">{{item.title}}</view>
				<view class="contentDesc two-line-ellipsis">{{item.desc}}</view>
				<view class="author">{{item.author}}</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import { ref } from 'vue';
	import request from '@/src/utils/request.js'
	import {
		useTransferStore
	} from '../../store/transfer';
	import {
		openOutside
	} from '@/src/utils/open-outside.js'

	const data = ref([])

	const toDetail = (url) => {
		openOutside(url)
	}

	request.getDailyHot(useTransferStore().payload).then(res => {
		data.value = res.data
	}).catch(console.error)
</script>

<style lang="scss" scoped>
	.container {
		width: 90%;
		margin: 20px auto;
		background-color: $uni-bg-color;
	}

	.hotItem {
		min-height: 100px;
		width: 100%;
		background-color: $uni-bg-color-grey;
		margin-bottom: 10px;
		display: flex;
		align-items: center;

		.pic {
			width: 100px;
			height: 100px;
			margin-right: 10px;
		}

		.itemContent {
			font-size: 14px;
			flex: 1;
			padding-right: 10px;

			.contentTitle {
				font-weight: bold;
			}

			.contentDesc {
				font-size: 12px;
			}

			.author {
				float: right;
				margin-right: 10px;
				color: gray;
			}
		}
	}
</style>